home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / ctrlpnl.exe / PMCTLPNL.FRM < prev    next >
Encoding:
Text File  |  1993-03-20  |  8.9 KB  |  343 lines

  1. Version 1.00
  2. BEGIN Form Ctrlpanl
  3.     AutoRedraw   = 0
  4.     BackColor    = QBColor(7)
  5.     BorderStyle  = 1
  6.     Caption      = "ControlPanel Properties"
  7.     ControlBox   = -1
  8.     Enabled      = -1
  9.     ForeColor    = QBColor(0)
  10.     Height       = Char(11)
  11.     Left         = Char(14)
  12.     MaxButton    = -1
  13.     MinButton    = -1
  14.     MousePointer = 0
  15.     Tag          = ""
  16.     Top          = Char(3)
  17.     Visible      = -1
  18.     Width        = Char(44)
  19.     WindowState  = 0
  20.     BEGIN HScrollBar HScroll1
  21.         Attached     = 0
  22.         DragMode     = 0
  23.         Enabled      = -1
  24.         Height       = Char(1)
  25.         LargeChange  = 1
  26.         Left         = Char(20)
  27.         Max          = 32767
  28.         Min          = 0
  29.         MousePointer = 0
  30.         SmallChange  = 1
  31.         TabIndex     = 5
  32.         TabStop      = 0
  33.         Tag          = ""
  34.         Top          = Char(3)
  35.         Value        = 0
  36.         Visible      = -1
  37.         Width        = Char(12)
  38.     END
  39.     BEGIN VScrollBar VScroll1
  40.         Attached     = 0
  41.         DragMode     = 0
  42.         Enabled      = -1
  43.         Height       = Char(5)
  44.         LargeChange  = 1
  45.         Left         = Char(33)
  46.         Max          = 32767
  47.         Min          = 0
  48.         MousePointer = 0
  49.         SmallChange  = 1
  50.         TabIndex     = 4
  51.         TabStop      = 0
  52.         Tag          = ""
  53.         Top          = Char(2)
  54.         Value        = 0
  55.         Visible      = -1
  56.         Width        = Char(1)
  57.     END
  58.     BEGIN CommandButton cmdSelUpdate
  59.         BackColor    = QBColor(7)
  60.         Cancel       = 0
  61.         Caption      = "&Update"
  62.         Default      = 0
  63.         DragMode     = 0
  64.         Enabled      = 0
  65.         Height       = Char(3)
  66.         Left         = Char(18)
  67.         MousePointer = 0
  68.         TabIndex     = 3
  69.         TabStop      = -1
  70.         Tag          = ""
  71.         Top          = Char(6)
  72.         Visible      = -1
  73.         Width        = Char(12)
  74.     END
  75.     BEGIN CommandButton cmdSelCancel
  76.         BackColor    = QBColor(7)
  77.         Cancel       = -1
  78.         Caption      = "&Cancel"
  79.         Default      = 0
  80.         DragMode     = 0
  81.         Enabled      = -1
  82.         Height       = Char(3)
  83.         Left         = Char(2)
  84.         MousePointer = 0
  85.         TabIndex     = 2
  86.         TabStop      = -1
  87.         Tag          = ""
  88.         Top          = Char(6)
  89.         Visible      = -1
  90.         Width        = Char(12)
  91.     END
  92.     BEGIN CommandButton cmdSelChange
  93.         BackColor    = QBColor(7)
  94.         Cancel       = 0
  95.         Caption      = "C&hange"
  96.         Default      = 0
  97.         DragMode     = 0
  98.         Enabled      = -1
  99.         Height       = Char(3)
  100.         Left         = Char(2)
  101.         MousePointer = 0
  102.         TabIndex     = 1
  103.         TabStop      = -1
  104.         Tag          = ""
  105.         Top          = Char(2)
  106.         Visible      = -1
  107.         Width        = Char(12)
  108.     END
  109.     BEGIN ComboBox cboControls
  110.         BackColor    = QBColor(7)
  111.         DragMode     = 0
  112.         Enabled      = -1
  113.         ForeColor    = QBColor(0)
  114.         Height       = Char(1)
  115.         Left         = Char(1)
  116.         MousePointer = 0
  117.         Sorted       = 0
  118.         Style        = 2
  119.         TabIndex     = 0
  120.         TabStop      = -1
  121.         Tag          = ""
  122.         Top          = Char(1)
  123.         Visible      = -1
  124.         Width        = Char(40)
  125.     END
  126. END
  127. '===============================================
  128. ' PMCTLPNL
  129. ' Allows updates to ControlPanel properties
  130. '   and saves the selections in a file
  131. '   called CTRLPANL.OPT
  132. '
  133. ' The original idea for this program came from
  134. '    the book
  135. ' VISUAL BASIC for MS-DOS Workshop
  136. '    by John Clark Craig
  137. '    published by Microsoft Press
  138. '
  139. ' The rest of the ideas are from Robert A. Blaney
  140. '  Chandero Systems, Inc.
  141. '  14 Parkview Rd.
  142. '  Long Valley, NJ 07853
  143. '
  144. '  This program is being termed freeware for the
  145. '   following reasons:
  146. '  1. I learned somethings about VB DOS
  147. '  2. I want you to be able to use this and
  148. '     experiment with it
  149. '  3. It will help pay back the work of others
  150. '
  151. '===============================================
  152. DEFINT A-Z
  153. DECLARE SUB GetColorSelect ()
  154. DECLARE SUB cmdSelChange_Click ()
  155. DECLARE SUB UpdateCtrlData ()
  156. '$INCLUDE: 'CONSTANT.BI'
  157.  
  158.  
  159. ' The current Control Panel index
  160. DIM SHARED CtrlIndx AS INTEGER
  161. ' Switch to indicate some changes were made to controls
  162. DIM SHARED CtrlChanged AS INTEGER
  163. ' Switch to indicate that file was saved
  164. DIM SHARED OutputSaved AS INTEGER
  165. ' to pass the selected color back
  166. COMMON SHARED HoldColorIndex AS INTEGER
  167.  
  168. DIM SHARED PMCtrl AS INTEGER
  169.  
  170. ' $FORM frmColSelect
  171. ' $FORM CtrlPanl
  172.  
  173. SUB cboControls_DblClick ()
  174. ' User double clicked on the list, invoke the select
  175.     CALL cmdSelChange_Click
  176. END SUB
  177.  
  178. SUB cboControls_GotFocus ()
  179. ' If the color was set then HoldColorIndex
  180. '  will have a value
  181.     IF HoldColorIndex <> 99 THEN
  182.     ' User selected a color for this item, update it
  183.         CtrlChanged = TRUE
  184.         OutputSaved = NOT CtrlChanged
  185.         Screen.ControlPanel(CtrlIndx) = HoldColorIndex
  186.         HoldColorIndex = 99     ' Done
  187.     END IF
  188.     cmdSelChange.Enabled = TRUE
  189.     cmdSelUpdate.Enabled = CtrlChanged
  190. END SUB
  191.  
  192. SUB cmdSelCancel_Click ()
  193. ' the cmdSelCancel is a DONE button
  194. ' Check if any changes were made and whether the
  195. '    output was saved, if not, give one last chance
  196.     IF CtrlChanged AND NOT OutputSaved THEN
  197.         x = MSGBOX("Save the Updates Made?", 3, "File Save")
  198.         IF x = 6 THEN      ' Yes
  199.             CALL UpdateCtrlData
  200.         ELSEIF x = 2 THEN
  201.             EXIT SUB
  202.         END IF
  203.     END IF
  204.     UNLOAD frmColSelect
  205.     UNLOAD CtrlPanl
  206.     CLOSE (10)
  207. END SUB
  208.  
  209. SUB cmdSelChange_Click ()
  210. ' User indicated to change the control selected
  211. '  in the list box, CtrlIndx points to entry in list
  212.     CtrlIndx = cboControls.ListIndex
  213.     IF CtrlIndx < 0 THEN
  214.         cboControls.SETFOCUS
  215.         EXIT SUB        ' nothing selected
  216.     END IF
  217.     ' get the current value
  218.     Tmp = Screen.ControlPanel(CtrlIndx)
  219.  
  220.     SELECT CASE CtrlIndx
  221.     CASE 0 TO 2, 4 TO 6, 8 TO 14, 16 TO 17
  222. ' These require color selections
  223.         HoldColorIndex = 99
  224.         frmColSelect.SHOW
  225.         frmColSelect.cmdColor(Tmp).SETFOCUS
  226.         EXIT SUB
  227.     CASE 7
  228.         Prompt$ = "Enter ASCII value (0-255) for desktop fill character"
  229.         Title$ = "Desktop Fill Character"
  230.         Defalt$ = STR$(Tmp)
  231.         DO
  232.             Tmp = VAL(INPUTBOX$(Prompt$, Title$, Defalt$))
  233.         LOOP UNTIL Tmp >= 0 AND Tmp < 256
  234.         CtrlChanged = TRUE
  235.     CASE 3, 15
  236.         Tmp = NOT Tmp
  237.         CtrlChanged = TRUE
  238.     END SELECT
  239.     Screen.ControlPanel(CtrlIndx) = Tmp
  240.     cmdSelUpdate.Enabled = CtrlChanged
  241.     OutputSaved = NOT CtrlChanged
  242. END SUB
  243.  
  244. SUB cmdSelUpdate_Click ()
  245. ' Update the control file with the Control Panel
  246. '   settings
  247.     CALL UpdateCtrlData
  248. END SUB
  249.  
  250. SUB Form_Load ()
  251.     LOAD frmColSelect   ' get the color select form
  252. 'Fill the first drop down box array
  253.     FOR i = 0 TO 17
  254.         SELECT CASE i
  255.         CASE 0
  256.             Tmp$ = "Access key foreground color "
  257.         CASE 1
  258.             Tmp$ = "Active border background color "
  259.         CASE 2
  260.             Tmp$ = "Active border foreground color "
  261.         CASE 3
  262.             Tmp$ = "Active window shadow effect "
  263.         CASE 4
  264.             Tmp$ = "Command-button foreground color "
  265.         CASE 5
  266.             Tmp$ = "Desktop background color "
  267.         CASE 6
  268.             Tmp$ = "Desktop foreground color "
  269.         CASE 7
  270.             Tmp$ = "Desktop fill pattern (ASCII 0-255)"
  271.         CASE 8
  272.             Tmp$ = "Disabled menu/dialog foregrd color "
  273.         CASE 9
  274.             Tmp$ = "Menu background color "
  275.         CASE 10
  276.             Tmp$ = "Menu foreground color "
  277.         CASE 11
  278.             Tmp$ = "Menu item selected backgrd color "
  279.         CASE 12
  280.             Tmp$ = "Menu item selected foregrd color "
  281.         CASE 13
  282.             Tmp$ = "Scroll bar background color "
  283.         CASE 14
  284.             Tmp$ = "Scroll bar foreground color "
  285.         CASE 15
  286.             Tmp$ = "3-D effect for control borders "
  287.         CASE 16
  288.             Tmp$ = "Title bar background color "
  289.         CASE 17
  290.             Tmp$ = "Title bar foreground color "
  291.         END SELECT
  292.         cboControls.ADDITEM Tmp$
  293.     NEXT i
  294.  
  295.  
  296. ' Get the Control Panel file, if it exists, and use
  297. '   the values that were stored last time.
  298. '  If it does not exist then it must be created, ask
  299. '   user if the file is to be created
  300.     FileOpen = TRUE
  301.     ON LOCAL ERROR GOTO NoFileFound
  302.  
  303.     OPEN "ctrlpanl.opt" FOR INPUT AS #10
  304.     ' The values are in the file, use them first
  305.     '  and load to ControlPanel also
  306.     FOR i = 0 TO 17
  307.         IF FileOpen THEN
  308.             INPUT #10, PMCtrl
  309.             Screen.ControlPanel(i) = PMCtrl
  310.         END IF
  311.         Tmp$ = STR$(Screen.ControlPanel(i))
  312.     NEXT i
  313.     CLOSE (10)
  314.     HoldColorIndex = 99     ' default
  315. ' Center Justify the form on the screen
  316.     CtrlPanl.Left = (Screen.Width - CtrlPanl.Width) \ 2
  317.     CtrlPanl.Top = (Screen.Height - CtrlPanl.Height) \ 2
  318.     EXIT SUB
  319.  
  320. NoFileFound:
  321. ' Open failed on input, set a switch to bypass reads
  322.     FileOpen = FALSE
  323.     RESUME NEXT
  324.  
  325. END SUB
  326.  
  327. SUB UpdateCtrlData ()
  328. ' Save the changes made to the Screen Controls
  329.     OPEN "ctrlpanl.opt" FOR OUTPUT AS #10
  330.     FOR i = 0 TO 17
  331.         PMCtrl = Screen.ControlPanel(i)
  332.         PRINT #10, PMCtrl
  333.     NEXT i
  334.     OutputSaved = TRUE
  335.     CLOSE (10)
  336. ' Change Cancel Button to Done
  337.     CtrlChanged = FALSE
  338.     cmdSelUpdate.Enabled = FALSE
  339.     cmdSelCancel.Caption = "&Done"
  340.     cmdSelCancel.SETFOCUS
  341. END SUB
  342.  
  343.